<div class="leiturasHs01 index">
<?php 
	echo $this->Html->css(array('jquery.datetimepicker'));
	echo $this->Html->script(array('jquery.datetimepicker'));
?>
	<h2>Leituras: <?php echo $estacao['nome']; ?></h2>
	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php echo $this->Paginator->sort('hora'); ?></th>
			<th><?php echo $this->Paginator->sort('estacao_id'); ?></th>
			<th><?php echo $this->Paginator->sort('precipitacao'); ?></th>
			<th><?php echo $this->Paginator->sort('sedimentos'); ?></th>
			<th><?php echo $this->Paginator->sort('nivel'); ?></th>
			<th><?php echo $this->Paginator->sort('vazao'); ?></th>
			<th><?php echo $this->Paginator->sort('bateria'); ?></th>
			<th class="actions"><?php echo __('Actions'); ?></th>
	</tr>
	<?php foreach ($leiturasHs01 as $leitura): ?>
	<tr>
		<td><?php echo h($leitura['LeiturasHs01']['hora']); ?>&nbsp;</td>
		<td>
			<?php echo $this->Html->link($leitura['Estacao']['nome'], array('controller' => 'estacoes', 'action' => 'view', $leitura['Estacao']['id'])); ?>
		</td>
		<td><?php echo h($leitura['LeiturasHs01']['precipitacao']); ?>&nbsp;</td>
		<td><?php echo h($leitura['LeiturasHs01']['sedimentos']); ?>&nbsp;</td>
		<td><?php echo h($leitura['LeiturasHs01']['nivel']); ?>&nbsp;</td>
		<td><?php echo h($leitura['LeiturasHs01']['vazao']); ?>&nbsp;</td>
		<td><?php echo h($leitura['LeiturasHs01']['bateria']); ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('View'), array('action' => 'view', 'pesquisador' => true, $leitura['LeiturasHs01']['sequencia'], $leitura['LeiturasHs01']['estacao_id'], str_replace(':','|',$leitura['LeiturasHs01']['hora']))); ?>
			<?php 
			if ($hasPermission['colaborador']) {
				echo $this->Html->link(__('Edit'), array('action' => 'edit', 'colaborador' => true, $leitura['LeiturasHs01']['sequencia'], $leitura['LeiturasHs01']['estacao_id'], str_replace(':','|',$leitura['LeiturasHs01']['hora'])));
				echo $this->Form->postLink(__('Delete'), array('action' => 'delete', 'colaborador' => true, $leitura['LeiturasHs01']['sequencia'], $leitura['LeiturasHs01']['estacao_id'], str_replace(':','|',$leitura['LeiturasHs01']['hora'])), null, 'Deseja apagar esta linha de leitura?');
			}
			?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
	));
	?>	</p>
	<div class="paging">
	<?php
		echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
		echo $this->Paginator->numbers(array('separator' => ''));
		echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
	?>
	</div>
</div>
<div class="actions">
	<h3><?php echo __('Actions'); ?></h3>
	<ul>
		<?php if ($hasPermission['colaborador']): ?>
			<li><?php echo $this->Html->link('Adicionar Leitura', array('action' => 'add', 'colaborador' => true, $estacao['id'])); ?></li>
		<?php endif; ?>
		<li><?php echo $this->Html->link('Lista de Estações', array('controller' => 'estacoes', 'action' => 'index', 'pesquisador' => true)); ?> </li>
		<?php if ($hasPermission['admin']): ?>
			<li><?php echo $this->Html->link('Nova Estação', array('controller' => 'estacoes', 'action' => 'add', 'admin' => true)); ?> </li>
		<?php endif; ?>
		<li>&nbsp;</li>
		<li><?php echo $this->Html->link('Exportar', '#', array('onclick' => 'showExport();')); ?></li>
	</ul>
</div>

<div class="dialogExport" style="display: none">
	<h3>Exportar no Intervalo:</h3>

	<?php echo $this->Form->create('LeiturasHs01', array('url' => array('action' => 'export', 'controller' => 'LeiturasHs01', 'pesquisador' => true, 'ext' => 'csv'))); ?>
		<p style="margin-left: 10px; padding:10px">
			<?php echo $this->Form->input('estacao_id', array('value' =>  $estacao['id'], 'type' => 'hidden')); ?>
			<?php echo $this->Form->input('startDate', array('class' => 'datePicker', 'div' => false, 'label' =>false)); ?>
			- 
			<?php echo $this->Form->input('endDate', array('class' => 'datePicker', 'div' => false, 'label' =>false)); ?>
		</p>

	<?php echo $this->Form->end(); ?>
	<button type="button" class="btn btn-success" onclick="exportar();">Exportar</button>
	<button type="button" class="btn btn-danger" style="float: right" onclick="closeExport();">Cancelar</button>
</div>

<script type="text/javascript">
	$(function(){
		$('.datePicker').datetimepicker({mask:'9999/19/39 29:59'});
	});

	function showExport() {
		$('.dialogExport').show();
	}

	function closeExport() {
		$('.dialogExport').hide();
	}

	function exportar() {
		$('#LeiturasHs01PesquisadorIndexForm').submit();

		closeExport();
	}

</script>